//
//  JMNavigationController.m
//  OC-Sina
//
//  Created by 陈高健 on 15/12/22.
//  Copyright © 2015年 陈高健. All rights reserved.
//

#import "JMNavigationController.h"

@interface JMNavigationController ()

@end

@implementation JMNavigationController

//点击跳转
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    
    NSString *title = @"返回";
    
    NSInteger count = self.childViewControllers.count;
    if (count >= 1) {
        if (count == 1) {
            title = [[self.childViewControllers firstObject] title];
        }
        //设置在push的使用隐藏tabBar
        viewController.hidesBottomBarWhenPushed = YES;
        
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImageName:@"navigationbar_back_withtext" title:title target:self action:@selector(back)];
    }
    
    [super pushViewController:viewController animated:YES];
}

//返回按钮
- (void)back{
    [self popViewControllerAnimated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
